package fragmentson;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wq.cycling.R;

import activity.SonActivity;
import fragmentson.backhandle.BackHandledFragment;

/**
 * 车辆报失信息填写
 * author：wangqi on 2017/4/26 17:48
 * email：773630555@qq.com
 */
public class ReportLoss_D extends BackHandledFragment {

	private View rootView;
	private Intent intent;
	private Bundle bundle;
	private String address="",price="";
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		rootView = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_reportloss_d, null);
		initView();
		return rootView;
	}

	public void initView(){
		((TextView) rootView.findViewById(R.id.tv_title)).setText(R.string.mycar_lose_message);
		rootView.findViewById(R.id.ll_address).setOnClickListener(listener);
		rootView.findViewById(R.id.ll_price).setOnClickListener(listener);
		rootView.findViewById(R.id.tv_sure).setOnClickListener(listener);
		((TextView) rootView.findViewById(R.id.tv_address)).setText(address);
		((TextView) rootView.findViewById(R.id.tv_price)).setText(price);
	}

	public static ReportLoss_D newInstance() {
		ReportLoss_D fragment = new ReportLoss_D();
		return fragment;
	}

	public View.OnClickListener listener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()){
				case R.id.ll_address:
					((SonActivity) getActivity()).addFragment(ReportLoss_E.newInstance(new ReportLoss_E.CallBackListener() {
						@Override
						public void listener(String item) {
							address = item;
						}
					}));
					break;
				case R.id.ll_price:
					((SonActivity) getActivity()).addFragment(ReportLoss_F.newInstance(price, new ReportLoss_F.CallBackListener() {
						@Override
						public void listener(String item) {
							price = item;
						}
					}));
					break;
				case R.id.tv_sure:
					((SonActivity) getActivity()).addFragment(Pay.newInstance());
					break;
			}
		}
	};

	@Override
	public boolean onBackPressed() {
		return false;
	}


}
